var xmlhttp;

function Checker(){
    var theValue = document.getElementById("in_user_id").value;				//Ambil value dari "id" textbox(Yang dilihat id bukan name-nya)
    if(theValue!=""){
        xmlhttp=GetXmlHttpObject();
        if (xmlhttp==null)
        {
            alert ("Browser does not support HTTP Request");
            return;
        }
        document.getElementById("imgTry").innerHTML="<img src='../asset/img/loading.gif' /> Checking!!";  
		
        var url="checker.php";
		
        url = url+"?value="+theValue;
		
        xmlhttp.onreadystatechange=stateChanged;
        xmlhttp.open("GET",url,true);
        xmlhttp.send(null);
    }
}

function stateChanged(){
    if (xmlhttp.readyState==4)
    {
        if(xmlhttp.responseText=="OK")
        {
            document.getElementById("imgTry").innerHTML="<img src='../asset/img/arrived.jpg'>OK, Username Tersedia!!!";	
        }
        else
        {
            document.getElementById("imgTry").innerHTML="<img src='../asset/img/unArrived.jpg'>Username sudah ada!!!";
        }
    }
}

function GetXmlHttpObject()
{
    if (window.XMLHttpRequest)
    {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        return new XMLHttpRequest();
    }
    if (window.ActiveXObject)
    {
        // code for IE6, IE5
        return new ActiveXObject("Microsoft.XMLHTTP");
    }
    return null;
}

